package com.baidu.dao;

import com.baidu.pojo.Exhibition;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ExhibitionMapper {
    //    查询全部展会
    @Select("SELECT * FROM exhibition WHERE estate=0 and etitle like #{name}")
    public List<Exhibition> getExhibition(String name);

    @Select("SELECT * FROM exhibition WHERE estate=0 and eid = #{eid}")
    public Exhibition getExhibitionById(Integer eid);
    //添加展会信息
    @Insert("INSERT INTO exhibition (epic,etitle,ebody,ebegin,etime,estate) \n" +
            "VALUES(#{epic},#{etitle},#{ebody},#{ebegin},#{etime},0)")
    public void addExhibition(Exhibition exhibition);

    //删除展会信息
    @Update("update exhibition set estate=1 where eid=#{eid}")
    public void deleteExhibition(Integer eid);

    //修改展会信息
    @Update("UPDATE exhibition SET epic=#{epic},etitle=#{etitle},ebody=#{ebody},ebegin=#{ebegin},etime=#{etime} \n" +
            "WHERE eid=#{eid};")
    public void updateExhibition(Exhibition exhibition);
    //分页查询总记录数
    @Select("select COUNT(*) from exhibition where estate!=1")
    public int count();
    //查询所有展会信息
    @Select("SELECT * FROM exhibition where estate!=1 limit #{start},#{pageSize}")
    public List<Exhibition> getByPage(@Param("start")Integer start, @Param("pageSize")Integer pageSize);
    //查询所有展会信息
    @Select("SELECT * FROM exhibition where estate!=1 and eid=#{eid}")
    public Exhibition getExhibitionByTid(Integer eid);

    //根据订单号修改订单信息
    @Update("UPDATE exhibition SET epic=#{epic},etitle=#{etitle},ebody=#{ebody},ebegin=#{ebegin},etime=#{etime} WHERE eid=#{eid}")
    public void updateExhibitionByOid(Exhibition exhibition);

    //查询所有展会
    @Select("SELECT eid,etitle FROM exhibition WHERE estate!=1")
    public List<Exhibition> getAllExhibition();
}
